<div class="modal-body">
	<form id="user-form" name="user-form" class="form-horizontal">
		<input type="hidden" name="optionId" id="optionId" value="">
		<input type="hidden" name="createTime" id="createTime" data-flag="date" data-format="yyyy-MM-dd HH:mm:ss">
		<input type="hidden" name="deviceid" id="deviceid" value="">
		<div class="box-body">
			<div class="col-md-12">
				<div class="form-group">
					<label for="device" class="col-sm-2 control-label">设备名称</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="devicename" name="devicename" placeholder="设备名称" readonly />
					</div>
				</div>
				<div class="form-group">
					<label for="device" class="col-sm-2 control-label">预警项名称</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="optionname" name="optionname" placeholder="预警项名称" />
					</div>
				</div>
				<div class="form-group">
					<label for="monitor_item" class="col-sm-2 control-label">预警项说明</label>
					<div class="col-sm-8">
						<textarea rows="5" class="form-control" id="description" name="description" placeholder="预警项说明"></textarea>
					</div>
				</div>
			</div>
		</div>
		<!-- /.box-body -->
		<div class="box-footer text-right">
			<!--以下两种方式提交验证,根据所需选择-->
			<button type="button" class="btn btn-default" data-btn-type="cancel" onclick="dialog_close()">取消</button>
			<button type="button" class="btn btn-primary" data-btn-type="save" onclick="save_station_warnoption()">提交</button>
		</div>
		<!-- /.box-footer -->
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		view_station_warnoption();
	});
	
	function view_station_warnoption( fn ){
		//从datatable上获取已经选择的条目
		if( Dtable_station_warnoption.rows('.selected').data().length > 0 ){
			var id = Dtable_station_warnoption.rows('.selected').data()[0].id;
			$("#optionId").val( id );
			
			if( id == "null" ||id == null || id == "undefined" || id == "0" ){
				return false;
			}
			var url = "../../tbl_station_warnoption/" + id;
			$.getJSON(url, null, function(json){
				//向页面上加载信息
				if( json && json.data ){
					var station_warnoption = json.data;
					$("#devicename").val(station_warnoption.devicename );
			 		$("#deviceid").val(station_warnoption.deviceid);
			 		$("#optionname").val(station_warnoption.optionname);
			 		$("#description").val(station_warnoption.description);
			 		$("#createTime").val(station_warnoption.createTime);
				}			
			});
		}
	}
	
	function save_station_warnoption(){
		var station_warnoption = {};
		station_warnoption.id = $("#optionId").val();
		station_warnoption.optionname = $("#optionname").val();
		station_warnoption.deviceid = $("#deviceid").val();
		station_warnoption.description = $("#description").val();
		station_warnoption.createTime = $("#createTime").val();	
		var json_data = JSON.stringify( station_warnoption );
		var url = "../../tbl_station_warnoption/save";
		$.ajax({
			  url: url,
			  type : 'post',
			  async : false,
			  data: json_data,
			  contentType: "application/json; charset=utf-8",
			  dataType: "json",
			  success: function(json) {
				 global.alert( json.message );
				 $("#station_info_main").load("station/station_info_list.html");
				 Dtable_station_warnoption.ajax.reload();
				 dialog_close();
			  }
		});
	}
	
	function dialog_close(){
		global.dialog.close()
	}
</script>